package com.itheima.reflectlearn;

import java.lang.reflect.Constructor;

/*
通过反射机制使用构造方法
 */
public class ReflectTest12 {
    public static void main(String[] args) throws Exception{
        Class vipClass = Class.forName("com.itheima.reflectlearn.Vip");
        //调用无参数构造方法
        Object obj = vipClass.newInstance();
        //调用有参数构造方法怎么办？
        //1.先获取这个有参数的构造方法
        Constructor constructor = vipClass.getDeclaredConstructor(String.class, String.class, int.class, int.class);
        Object newobj = constructor.newInstance("张三","男",13245,22);

        System.out.println(newobj);


    }


}
